<template>
    <div class="child">
        <h2>我是子组件</h2>
        <h4>玩具：{{ toy }}</h4>
        <h4>父组件给的数据：{{ che }}</h4>
        <button @click="sendToy">给父组件传数据</button>
    </div>
</template>

<script lang="ts" setup name="Child">
import {ref} from "vue";

let toy = ref('奥特曼')
let x = defineProps(['che','getFromToy'])
function sendToy() {
    x.getFromToy(toy)
}
</script>

<style scoped>
.child {
    height: 300px;
    width: 80%;
    background-color: aliceblue;
}
</style>
